import { Modal } from 'antd';
import { StringUtil } from '../../utils/string_util';

export function confirmDlg(type: string, onOk: (func: Function) => any, action: string = 'delete', target: string = '') {
    if (action === 'delete') {
        action = '删除';
    } else if (action === 'disband') {
        action = '解散';
    }
    if (type === 'record') {
        type = '记录';
    } else if (type === 'collection') {
        type = '分类';
    }else if (type === 'project') {
        type = '项目';
    }else if (type === 'environment') {
        type = '环境';
    }else if (type === 'schedule') {
        type = '计划任务';
    }else if (type === 'stress') {
        type = '压力测试';
    }
    Modal.confirm({
        title: `${StringUtil.upperFirstAlphabet(action)} ${type}`,
        content: `你想要 ${action} 这个 ${type}${target ? ': ' : ''}${target}, 是么?`,
        okText: '确认',
        cancelText: '取消',
        onOk: onOk,
    });
}